home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 076-100 / scopedisk86 / im_example / im_exmpl.c < prev   
Encoding:
C/C++ Source or Header  |  1995-03-19  |  2.1 KB  |  97 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3.  
  4. #define INTUITION_REV   0
  5. #define GRAPHICS_REV    0
  6.  
  7. struct IntuitionBase *IntuitionBase;
  8. struct GfxBase *GfxBase;
  9. struct RastPort *rp;
  10. struct Window *image_window;
  11.  
  12. USHORT chip imagedefs[]={0xffff,0x7ffe,0xbffd,0xdffb,
  13.                                           0xeff7,0xf7ef,0xffff,0xffff,
  14.                                                  0xffff,0xffff,0xf7ef,0xeff7,
  15.                                                  0xdffb,0xbffd,0x7ffe,0xffff};
  16.                                                   
  17. struct Image myimage={0,0,16,16,3,&imagedefs[0],0x1,0x0,NULL};
  18.     
  19. main()
  20. {
  21.     ULONG flags;
  22.     SHORT x,y,w,h;
  23.     UBYTE color0,color1,*name;
  24.     int i;
  25.     
  26.     OpenLibs();
  27.     
  28.     x=y=0;
  29.     w=640;
  30.     h=200;
  31.     name="                             Image Example Window";
  32.     flags=ACTIVATE|SMART_REFRESH;
  33.     color0=0x0000;
  34.     color1=0x0001;
  35.     image_window=(struct Window*)make_window(x,y,w,h,name,flags,color0,color1,NULL,NULL);
  36.  rp=image_window->RPort;
  37.     
  38.     DrawImage(rp,&myimage,302,90);
  39.  
  40.     Delay(500);
  41.     CloseWindow(image_window);
  42.     CloseLibrary(IntuitionBase);
  43. };
  44.  
  45. make_window(x,y,w,h,name,flags,color0,color1,screen)
  46. SHORT x,y,w,h;
  47. UBYTE *name,color0,color1;
  48. ULONG flags;
  49. struct Screen *screen;
  50. {
  51.  struct NewWindow NewWindow;
  52.  NewWindow.LeftEdge = x;
  53.  NewWindow.TopEdge = y;
  54.  NewWindow.Width = w;
  55.  NewWindow.Height = h;
  56.  NewWindow.DetailPen = color0;
  57.  NewWindow.BlockPen = color1;
  58.  NewWindow.Title = name;
  59.  NewWindow.Flags = flags;
  60.  NewWindow.IDCMPFlags = CLOSEWINDOW|VANILLAKEY;
  61.  if(screen==NULL)
  62.   NewWindow.Type=WBENCHSCREEN;
  63.  else
  64.   {
  65.    NewWindow.Type=CUSTOMSCREEN;
  66.    NewWindow.Screen=screen;
  67.   }          
  68.   NewWindow.FirstGadget = NULL;
  69.   NewWindow.CheckMark = NULL;
  70.   NewWindow.BitMap = NULL;
  71.   NewWindow.MinWidth = 10;
  72.   NewWindow.MinHeight = 10;
  73.   NewWindow.MaxWidth = 640;
  74.   NewWindow.MaxHeight = 200;
  75.   return(OpenWindow(&NewWindow));
  76. }
  77.  
  78. OpenLibs()
  79. {
  80.  IntuitionBase=(struct IntuitionBase*)OpenLibrary("intuition.library",0);
  81.  if(IntuitionBase==NULL)
  82.  {
  83.   printf("Can't Open Intuition Library... Aborting !");
  84.   exit(FALSE);
  85.  } 
  86.  
  87.  GfxBase=(struct GfxBase*)OpenLibrary("graphics.library",0);
  88.  if(GfxBase==NULL)
  89.  {
  90.   printf("Can't Open Graphics Library... Closing Intuition... Aborting !");
  91.   CloseLibrary(IntuitionBase);
  92.   exit(FALSE);
  93.  } 
  94.  return(NULL);
  95. }
  96.  
  97.